<template>
  <!-- 历史消息 -->
  <div>
    <div class="header boxsizing">历史消息</div>
    <div class="mainpadding boxsizing">
      <div class="margin-top1">
        <el-date-picker size="small" v-model="time" type="month" placeholder="选择月">
        </el-date-picker>
      </div>
      <newsList ref="newsrefs" :newstype="{ classify: 2, genre: '', time: params.time }" />
    </div>
  </div>
</template>

<script>
import allRead from "./components/allRead.vue"
// import newsList from "./components/newsList.vue"
import newsList from "./components/newsList.vue"
export default {
  components: {
    allRead,
    newsList
  },
  data(){
    return{
      params:{
        time:this.date(Number(new Date())),
        pageNum:1,
        pageSize:10,
      },
      time: Number(new Date())
    }
  },
  watch:{
    time(newvalue){
      this.params.time = this.date(Number(newvalue))
    }
  },
  methods:{
    date(timer) {
      var date = new Date(timer); //当前时间
      var year = date.getFullYear() //返回指定日期的年份
      var month = repair(date.getMonth() + 1); //月
      var day = repair(date.getDate()); //日
      var curTime = year + "-" + month
      function repair(i) {
        if (i >= 0 && i <= 9) {
          return "0" + i;
        } else {
          return i;
        }
      }
      return curTime
    },
  },
}
</script>

<style lang="scss" scoped>
.header {
  height: 50px;
  border-bottom: 1px solid #e4e4e4;
  line-height: 50px;
  padding-left: 30px;
}
</style>